package com.java.service.impl;

import com.java.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class RedisTokenServiceImpl implements TokenService {

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public void save(String token) {
        redisTemplate.opsForSet().add("tokens", token);
    }

    @Override
    public void remove(String token) {
        redisTemplate.opsForSet().remove("tokens", token);
    }

    @Override
    public boolean exists(String token) {
        return redisTemplate.opsForSet().isMember("tokens", token);
    }

}
